package com.dbs.donatebooksystem.mapper;

import com.dbs.donatebooksystem.pojo.Address;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressMapper {
    @Select("select * from address where user_id=#{id}")
    List<Address> selectAddressById(int id);

    @Insert("INSERT INTO address(user_id, receiver_name, receiver_phone, detail_address) " +
            "VALUES (#{userId}, #{addr.receiverName}, #{addr.receiverPhone}, #{addr.detailAddress})")
    void insertAddress(@Param("userId") int id, @Param("addr") Address address);

    @Update("update address set detail_address=#{addr.detailAddress} where address_id=#{addr.addressId}")
    void updateAddress(@Param("addr")Address address);

    @Delete("delete from address where address_id=#{id}")
    void deleteAddress(@Param("id") Integer id);

    @Select("select * from address where address_id = #{addressId}")
    Address selectByAddressId(int addressId);
}
